/**
 * Configures the Bulk Move form
 */
function init (settings) {
	
	// Locate the freshly added form
	var form = $("#copy");
	var FileManager = this;
	var SourceTeamSite, SourceWorkspace;
	var DestinationTeamSite, DestinationWorkspace;
	
	// Add dynamic content to the form
	
	form.fields("filter").parent ().subform ();
	$("fieldset").collapsable();
	$("textarea").elastic();
	
	form.fields("bm_src_select", "bm_dest_select").click(function () {
		alert ("Not yet supported!");
	});
	
	// Process the Move Files form
	form.submit(function () {
		
		// File collection
		var FilesToMove = [];
		var SourceWorkspace = new Workspace (form.fields("bm_src_url").val());
		var DestinationWorkspace = new Workspace (form.fields("bm_dest_url").val());
		
		
		// Apply filter to the collection of files
		switch (form.fields("filter").filter(":checked").val()) {
			case "none":
				FilesToMove = SourceWorkspace.Documents;
				break;
			case "wildcard":
				
				break;
			case "pattern":
				var Pattern = new RegExp (form.fields("pattern").val());
				for (Index in SourceWorkspace.Files) {
					var Filename = SourceWorkspace.Files[Index];
					if (Pattern.test (Filename)) {
						FilesToMove.push(Filename);
					}
				}
				break;
			case "list":
				FilesToMove = form.fields("list").val().split("\n");
				break;
			default:
				Log.warn ("Unknown filter option selected while trying to move files!");
				return false;
		}
		
		var success = false;
		
		// Move the files in the collection
		for (Index in FilesToMove) {
			var Filename = FilesToMove[Index];
			if (confirm ("Move " + Filename + " from " + SourceWorkspace.Title + " to " + DestinationWorkspace.Title + "?")) {
				SourceWorkspace.Move (Filename, DestinationWorkspace);
				success = true;
			}
			
		}
		
		// Report back to the user
		if (success) {
			Log.inform ("Selected files were moved from " + SourceWorkspace.Title + " to " + DestinationWorkspace.Title);
		} else {
			Log.inform ("No files were moved from " + SourceWorkspace.Title + " to " + DestinationWorkspace.Title);
		}
		
		// Finish bulk move operation
		return false;
	});
}